<template>
   <van-nav-bar title="订单列表" left-text="返回" fixed left-arrow @click-left="onClickLeft" />
   <div style="height: 50px;"></div>
   <div>
      <p>你的订单已经生成{{ orderData.product_code }}</p>
      <p>用户名为{{orderData.username}}</p>
      <p>总结为{{orderData.totalPrice/100}}</p>
   </div>
    <van-submit-bar :price="orderData.totalPrice" button-text="提交订单" @submit="onSubmit" @click="onSubmit"/>
</template>

<script setup>
import { ref } from 'vue';
import { useRoute} from 'vue-router'
let route=new useRoute()
import {DetailOrderApi} from '@/api/api'
import { useCounterStore } from '@/stores/cart'
const stores = useCounterStore()
let orderData=ref([])
DetailOrderApi(route.params.orderid).then(res=>{
   console.log('订单数据',res)
   orderData.value=res.data.data

   paydata.value={
      orderId:res.data.data.orderId,
      subject:res.data.data.product_code,
      totalPrice:res.data.data.totalPrice/100
   }
})
import { payApi } from '@/api/api';
let paydata=ref({
   orderId:'',
   subject:'',
   totalPrice:0
})
const onSubmit=()=>{
   console.log(paydata.value)
   payApi(paydata.value).then(res=>{
      window.open(res.data.data,'_blank')
   })
}
</script>

<style lang="scss" scoped>

</style>